<!-- src/views/knowledge/Overview.vue -->
<template>
  <div class="knowledge-overview">
    <!-- 统计信息卡片 -->
    <el-card shadow="never" class="stats-card">
      <el-row :gutter="20" class="stats-row">
        <el-col :span="6" v-for="(stat, index) in stats" :key="index">
          <div class="stat-item">
            <div class="label">{{ stat.label }}</div>
            <div class="value">{{ stat.value }}</div>
            <div class="change">{{ stat.change }}</div>
          </div>
        </el-col>
      </el-row>
    </el-card>

    <!-- 近期文章 -->
    <el-card shadow="never" class="recent-card" style="margin-top: 20px">
      <template #header>
        <div class="card-header">
          <span>近期文章</span>
          <el-button type="text" @click="showAllArticles">查看全部 ></el-button>
        </div>
      </template>
      <el-table :data="recentArticles" style="width: 100%">
        <el-table-column prop="title" label="标题" />
        <el-table-column prop="views" label="展现" />
        <el-table-column prop="reads" label="阅读" />
        <el-table-column prop="comments" label="评论" />
        <el-table-column prop="likes" label="点赞" />
        <el-table-column prop="favorites" label="收藏" />
      </el-table>
    </el-card>


  </div>
</template>

<script setup>
import { ref } from 'vue';
import { useRouter } from 'vue-router';

const router = useRouter();

// 统计数据
const stats = ref([
  { label: '总阅读量', value: 4715, change: '昨日无变化' },
  { label: '累计收益', value: '¥0', change: '昨日无变化' },
  { label: '粉丝数', value: 0, change: '昨日无变化' },
  { label: '收藏数', value: 8, change: '昨日无变化' }
]);

// 近期文章
const recentArticles = ref([
  {
    title: 'RabbitMQ学习（初级阶段）',
    views: 1569,
    reads: 142,
    comments: 0,
    likes: 0,
    favorites: 0
  },
  {
    title: 'zip解压缩，亲测有效！！！',
    views: 2513,
    reads: 693,
    comments: 0,
    likes: 0,
    favorites: 0
  }
]);


// 跳转方法
const showAllArticles = () => {
  router.push('/knowledge/articles');
};

const showAllResources = () => {
  router.push('/knowledge/resources');
};
</script>

<style scoped>
.stats-card {
  padding: 20px;
}

.stats-row {
  display: flex;
  justify-content: space-between;
}

.stat-item {
  text-align: center;
  padding: 10px;
}

.label {
  font-size: 14px;
  color: #666;
}

.value {
  font-size: 24px;
  font-weight: bold;
  margin: 8px 0;
  color: #333;
}

.change {
  font-size: 12px;
  color: #999;
}

.recent-card {
  padding: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}
</style>
